SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE Proc [dbo].[SP_TTCNTB_EMPR_I01]    
/*-------------------------------------------------------------*/    
/*----- Cliente           : OFISIS S.A.                    ----*/    
/*----- Empresa           : OFISIS S.A.                    ----*/    
/*----- Sistema           : Contabilidad                   ----*/    
/*----- Modulo            : Administracion                 ----*/    
/*----- Programa          : Copia de Contabilidades        ----*/    
/*----- Nombre            : SP_TTCNTB_EMPR_I01             ----*/    
/*----- Script            : TTCNTB_EMPR                    ----*/    
/*----- Desarrollado por  : Franco Gamboni Koifman         ----*/    
/*----- Fecha             : 24/08/2001                     ----*/    
/*----- Base de Datos     : SQL Server                     ----*/    
/*----- Version BD        : 2000                           ----*/    
/*-------------------------------------------------------------*/    
/*-------------------------------------------------------------*/    
/*----- Modificado 1 por : percy garcia                    -----*/    
/*----- Fecha Modifica   : 05/06/2004                      -----*/    
/*----- Detalle Modifica : usuario creacion y modif        -----*/    
/*--------------------------------------------------------------*/  
/*---------------------------------------------------------------------*/        
/*----- Modificado 2 por : Gustavo Espinoza E.                    -----*/        
/*----- Fecha Modifica   : 31/03/2005                             -----*/        
/*----- Detalle Modifica : Grabar Usuario y Fecha del APT         -----*/        
/*---------------------------------------------------------------------*/     
/*---------------------------------------------------------------------*/        
/*----- Modificado 3 por : pdgv                              -----*/        
/*----- Fecha Modifica   : 23/10/2006                             -----*/        
/*----- Detalle Modifica : copia nuevos ids   -----*/        
/*---------------------------------------------------------------------*/     
/*-------------------------------------------------------------*/    
/*----- Drop procedure SP_TTCNTB_EMPR_I01                  ----*/    
/*----- Grant all on SP_TTCNTB_EMPR_I01 to PUBLIC          ----*/    
/*----- SP_TTCNTB_EMPR_I01 '01',1,2,'PRUEBA 2','DOL'       ----*/    
/*-------------------------------------------------------------*/    
(@ISCO_EMPR  Varchar(02),    
@ISCO_USUA          TD_VC_008,
@IDFE_USUA          TD_DT_001,
 @INNU_CNTB_EMP1 Integer,    
 @INNU_CNTB_EMP2 Integer,    
 @ISDE_CNTB_EMPR Varchar(50),    
 @ISCO_MONE      Varchar(03))    
 
As    
    
Declare    
@VSCO_EMPR Varchar(02)    
    
Insert into TTCNTB_EMPR(CO_EMPR,NU_CNTB_EMPR,DE_CNTB_EMPR,CO_MONE,ST_GENE_ASTO,ID_COMP,    
                        ID_VENT,ID_DIFE,ID_GANA_CAMB,ID_PERD_CAMB,ID_GANA_REDO,ID_PERD_REDO,    
                        ID_IMPT_RENT,ID_IMPT_VENT,ID_FONA,ID_GEST,ID_CIER,ID_APER,ID_AJUS_INFL,    
                        ID_FLEF,ID_IMPO,ID_QUIN,ID_CUAR,ID_TRIB,ID_EXTO, ID_BNCO,     
                        ID_DIST_AUXI, ID_DIST_OSER, ID_0001,ID_0002,ID_0003,ID_0004,    
                        ID_0005,ID_0006, NU_FACT_REDO, CO_USUA_MODI, FE_USUA_MODI, CO_USUA_CREA, FE_USUA_CREA,
ID_DIST_CNTA,ID_CTAS_PROD, ID_CTAS_INVE,ID_RENT_NDOM,ID_GAST_NGRA,ID_0007,ID_IIGV_PERC,ID_COBR_DIVE,ID_PROV_CODU,ID_PAGA_DIVE
)    
Select @ISCO_EMPR,@INNU_CNTB_EMP2,@ISDE_CNTB_EMPR,@ISCO_MONE,ST_GENE_ASTO,ID_COMP,ID_VENT,ID_DIFE,    
ID_GANA_CAMB,ID_PERD_CAMB,ID_GANA_REDO,ID_PERD_REDO,ID_IMPT_RENT,ID_IMPT_VENT,    
ID_FONA,ID_GEST,ID_CIER,ID_APER,ID_AJUS_INFL,ID_FLEF,ID_IMPO,ID_QUIN,ID_CUAR,    
ID_TRIB,ID_EXTO, ID_BNCO, ID_DIST_AUXI, ID_DIST_OSER, ID_0001,ID_0002,ID_0003,
ID_0004,ID_0005,ID_0006, NU_FACT_REDO, @ISCO_USUA, @IDFE_USUA, @ISCO_USUA, @IDFE_USUA,
ID_DIST_CNTA,ID_CTAS_PROD, ID_CTAS_INVE,ID_RENT_NDOM,ID_GAST_NGRA,ID_0007,ID_IIGV_PERC,ID_COBR_DIVE,ID_PROV_CODU,ID_PAGA_DIVE
From TTCNTB_EMPR    
Where    
CO_EMPR = @ISCO_EMPR AND NU_CNTB_EMPR = @INNU_CNTB_EMP1    
    
Insert Into TTIDEN_CNTA (CO_EMPR,NU_CNTB_EMPR,ID_CNTA,NU_ANNO, CO_CNTA_EMPR, CO_USUA_MODI, FE_USUA_MODI, CO_USUA_CREA, FE_USUA_CREA)    
--Select @ISCO_EMPR,@INNU_CNTB_EMP2,ID_CNTA,DATEPART(YYYY, @IDFE_USUA), CO_CNTA_EMPR, USER, @IDFE_USUA, USER, @IDFE_USUA    
Select @ISCO_EMPR,@INNU_CNTB_EMP2,ID_CNTA,9999, CO_CNTA_EMPR, @ISCO_USUA, @IDFE_USUA, @ISCO_USUA, @IDFE_USUA    
From TTIDEN_CNTA    
Where    
CO_EMPR = @ISCO_EMPR AND NU_CNTB_EMPR = @INNU_CNTB_EMP1    
    
Insert Into TTIDEN_OPER (CO_EMPR,NU_CNTB_EMPR,ID_OPRC,CO_OPRC_CNTB, CO_USUA_MODI, FE_USUA_MODI, CO_USUA_CREA, FE_USUA_CREA)    
Select @ISCO_EMPR,@INNU_CNTB_EMP2,ID_OPRC,CO_OPRC_CNTB, @ISCO_USUA, @IDFE_USUA, @ISCO_USUA, @IDFE_USUA    
From TTIDEN_OPER    
Where    
CO_EMPR = @ISCO_EMPR AND NU_CNTB_EMPR = @INNU_CNTB_EMP1    
    
Return    
/*--------------------- Fin ------------------------------*/    


GO
